#ifndef _HY1C_OUT_H
#define _HY1C_OUT_H

#include <stdio.h>
#include <stdarg.h>
#include <time.h>

// This file used as a common header file in all .c.

typedef enum
{
    LogLevel_begin = -1,
    LogLevel_Debug,
    LogLevel_Info,
    LogLevel_Warn,
    LogLevel_Error,
    LogLevel_end
} LogLevel_em;

extern LogLevel_em g_log_level;

extern FILE * g_pLog;

#ifdef __cplusplus
extern "C" {
#endif

int write_log (LogLevel_em logLevel,
                      const char *file,
                      const char *func,
                      const int line,
                      const char *format, ...);

#ifdef __cplusplus
}
#endif

#define LOG_DBG(_fmt, ...) do {write_log(LogLevel_Debug, __FILE__, __func__, __LINE__, _fmt, ##__VA_ARGS__);}while (0)
#define LOG_INFO(_fmt, ...) do {write_log(LogLevel_Info, __FILE__, __func__, __LINE__, _fmt, ##__VA_ARGS__);}while (0)
#define LOG_WARN(_fmt, ...) do {write_log(LogLevel_Warn, __FILE__, __func__, __LINE__, _fmt, ##__VA_ARGS__);}while (0)
#define LOG_ERR(_fmt, ...)  do {write_log(LogLevel_Error, __FILE__, __func__, __LINE__, _fmt, ##__VA_ARGS__);}while(0)

#define HY1C_out(_fmt, ...) do {write_log(LogLevel_Debug, __FILE__, __func__, __LINE__, _fmt, ##__VA_ARGS__);}while (0)
#define fHY1C_out(fp,_fmt, ...) do {write_log(LogLevel_Debug, __FILE__, __func__, __LINE__, _fmt, ##__VA_ARGS__);}while (0)

#endif /* _HY1C_OUT_H */
